﻿# coding: utf-8

class CCommand:
    """
    This is the base class of all commands.
    Every concrete command must derive from this class and be used by 'HISTORY_MANAGER'.
    So that the editor can have the ability of 'Undo/Redo' the command.
    For those operations which have no need to do 'Undo/Redo', don't derive from this
    class, and don't use 'HISTORY_MANAGER'.
    """
    
    def __init__(self, name, **p):
        """
        Default class constructor
        
        Parameters:
        @param name - the name of the command
        @param **p - the parameter dictionary used by concrete command
        """
        
        self._name = name
        self._paramDict = p
        
    def DoCmd(self):
        """ Abstract interface """
        
        raise NotImplementedError
        
    def UndoCmd(self):
        """ 
        Abstract interface 
        
        return False to make this command invalid.
        """
        
        raise NotImplementedError
        return True